package main

func binarySearch(nums []int, target int) int {
	left, right := 0, len(nums)-1
	for left <= right {
		m := left + (right-left)/2
		if target == nums[m] {
			return m
		} else if target > nums[m] {
			left = m + 1
		} else {
			right = m - 1
		}
	}
	return -1
}
